﻿<?php include("conn.php");
    mysql_query('SET NAMES UTF8'); 

    $ordersid = $_REQUEST['ordersid'];

    $result_data_array = array();
    if(!$ordersid){
    	$result_data_array['code'] = -100;
    	$result_data_array['msg'] = '订单信息错误';
    	echo json_encode($result_data_array);
    	exit;
    }
	mysql_query("BEGIN");
	
	mysql_query("COMMIT"); 
	mysql_query("END");
    $goodsorders_sql = "DELETE FROM goodsorders where ordersid = $ordersid";
    $car_sql = "DELETE FROM goodsorders where ordersid = $ordersid";

    $goodsorders_query = mysql_query($goodsorders_sql);
    if(!$goodsorders_query){
    	mysql_query("ROLLBACK"); 
		mysql_query("END"); 
    	$result_data_array['code'] = -100;
    	$result_data_array['msg'] = '删除订单失败';
    	echo json_encode($result_data_array);
		exit;
    }

    $car_query = mysql_query($car_sql);
    if(!$car_query){
    	mysql_query("ROLLBACK"); 
		mysql_query("END"); 
    	$result_data_array['code'] = -100;
    	$result_data_array['msg'] = '删除订单失败';
    	echo json_encode($result_data_array);
		exit;
    }

			
		


	$result_data_array['code'] = 200;
	$result_data_array['msg'] = '删除订单成功';
	echo json_encode($result_data_array);


?>